/**
 * Created by asus on 2017/3/7.
 */
define(['jquery','template','util','jquerycookie','jquerytoTop'],function($,template,util,undefine,undefine){
    //function getQueryString(key) {
    //    var search = location.search.slice(1);
    //    //console.log(search);
    //    var searchArr = search.split('&');
    //    var tempArr = [];
    //    var objString = {};
    //    for (var i = 0; i < searchArr.length; i++) {
    //        tempArr = searchArr[i].split('=');
    //        objString[tempArr[0]] = tempArr[1];
    //        return arguments.length ? objString[key] : objString;
    //    }
    //    //console.log(objString);
    //    //}
    //}
    var proName;
    var productId=util.getQueryString('productid');
    //var bjShop;
    $.ajax({
        url:'http://139.199.157.195:9090/api/getproduct',
        type:'get',
        data:{
            productid:productId,
        },
        success:function(data){
            //console.log(data.result);
            var tempcookie=data.result[0]['productName']
            tempcookie=tempcookie.split(' ');
            tempcookie=tempcookie.slice(0,1);
            proName=tempcookie.join('');
            $('.shopNamecut').html(proName+'>');
            //console.log(tempcookie);
            //$.cookie('productname',tempcookie);
            //$('.shopNamecut').text($.cookie('productname')+" >");
            console.log(data.result);
            //bjShop=data.result[0][bjShop];
            //console.log(bjShop);
            $('#contain').html(template('alldate',{list:data.result}));
           console.log($('.table')) ;
            $('.table').html(data.result[0]['bjShop']);
            console.log(data.result[0]['bjShop']);
        }
    })
    $.ajax({
        url:'http://139.199.157.195:9090/api/getproductcom',
        type:'get',
        data:{productid:productId},
        success:function(data){
          $('.totalpinrun').html('评论('+data.result.length+')');
            $('#pingjiaList').html(template('pingjiaTemp',{pingjiaList:data.result}));
        }
    })
    //console.log($.cookie('category'));
    //console.log($.cookie('productname'));
    $('.feilei').text(localStorage.getItem('fenlei')+'>');

    $('.feilei').on('click',function(){
        history.back();
    });
    $('.index').on('click',function(){
        location.href='../../index.html';
    });
    $('.totoop').toTop();
})